package springframework.beans;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lzp
 * @Date:2023/3/14
 * @description: 字段属性集
 */
public class PropertyValues {

	private final List<PropertyValue> propertyValueList = new ArrayList<>();

	public void addPropertyValue(PropertyValue propertyValue) {
		this.propertyValueList.add(propertyValue);
	}

	/**
	 * 获取字段属性集合
	 *
	 * @return
	 */
	public PropertyValue[] getPropertyValues() {
		return this.propertyValueList.toArray(new PropertyValue[0]);
	}

	/**
	 * 桶属性名获取属性对象
	 *
	 * @param propertyName 属性名称
	 * @return
	 */
	public PropertyValue getPropertyValue(String propertyName) {
		for (PropertyValue propertyValue : this.propertyValueList) {
			if (propertyValue.getName().equals(propertyName)) {
				return propertyValue;
			}
		}
		return null;
	}

}
